<#import "/crud/macro/global.ftl" as crud>

<#assign val_form = "cmxform" in crud />

<#assign need_autocomplete = false />
<#if row?exists>
<#assign fkFieldList = row.getFkInfoList() />
	<#if (fkFieldList?size > 0)>
		<#assign ext_js_list = ['jquery.autocomplete.js'] in crud />
		<#assign ext_css_list = ['jquery.autocomplete.css', 'autocomplete.css'] in crud />
		<#assign need_autocomplete = true />
	</#if>
</#if>

<@crud.body title=locale.title_prefix?if_exists + "--" + locale.view_one_title?if_exists>


<#if row?exists>
<div class="view_one_div">
	<form class="niceform" id="cmxform" method="post" action="${crud.crudUrl}" onsubmit="return check_submit(this);">
		<input type="hidden" id="can_submit_v" name="" value="1" />
		
		<input type="hidden" id="model" 
				name="model" value="${model_crud_url?if_exists}" />
		<input type="hidden" id="opt" 
				name="opt" value="updatepost" />
				
		<fieldset>
		<legend>${locale.view_one_form_legend?if_exists}</legend>
		<#list row.fields as field>
		<#if field.isPk()>
		<input type="hidden" id="pk_${field.name?if_exists}" 
				name="pk_${field.name?if_exists}" value="${field.value?if_exists}"/>
		</#if>
		<p>
			<label class="left" for="field_${field.name?if_exists}">${field.name?if_exists}</label>
			<span class="opt_img">
				<#if field.isPk()><img src="${crud.beginPath}images/opt/key.gif" title="${locale.primary_key_label?if_exists}" />
				<#elseif field.isRestrict("required") ||  field.isRestrict("password")><img src="${crud.beginPath}images/opt/required.gif" title="${locale.required_label?if_exists}" /></#if>
			</span>
			<#if field.type == "text">
			<div style="clear: both;"></div>
			<div style="margin-left: 20px;">
			<textarea id="field_${field.name?if_exists}" 
				name="field_${field.name?if_exists}" cols="35" rows="5">${field.value?if_exists}</textarea>
			</div>
			<#elseif field.type == "blob" && field.mod > 1>
			<div style="clear: both;"></div>
			<input type="file" size="20" />
			<#elseif field.type == "tinyint">
			${locale.yes_label?if_exists}<input type="radio" id="field_${field.name?if_exists}" 
				name="field_${field.name?if_exists}" <#if field.value == 1>checked </#if>/> 
			${locale.no_label?if_exists}<input type="radio" id="field_${field.name?if_exists}" 
				name="field_${field.name?if_exists}" <#if field.value == 0>checked </#if>/> 
			<#else>
			<input id="field_${field.name?if_exists}" 
				name="field_${field.name?if_exists}" size="20" value="${field.value?if_exists}" 
				<#if field.isRestrict("required")>restrict="${field.restrict?if_exists}" </#if>
				<#if field.isRestrict("password")>type="password" </#if>
				<#if field.isFk()>
				<#assign url = crud.crudUrl + "?model=" + field.fkModel + "&field=" + field.name + "&opt=autocomplete" />
				onkeyup="lookup('${url}', this.value);" 
				</#if>
				<#if (field.mod == 1)>disabled="true" title="${locale.disabled_label?if_exists}" </#if>/><br />
			</#if>
		</p>
		</#list>
		<div style="clear:both"></div>
		<p>
			<input id="submit" type="submit" value="${locale.update_label?if_exists}"/>
		</p>
		</fieldset>
	</form>
	<div style="clear: both;"></div>
	<#-- Ralition Row List
	<#assign relationMap = row.relationRowList />
	<#list relationMap?keys as field_key>
	<#assign subList = relationMap[field_key] />
	<span class="relation_row_list_header" id="fk_field_${field_key}" onclick="scroll('fk_field_${field_key}_relation');"></span>
	<div class="relation_row_list_div" id="fk_field_${field_key}_relation">
	<ul>
	<#list subList as subRow>
		<li>${subRow.getFieldsString(0)}</li>
	</#list>
	</ul>
	</div>
	</#list>
	 -->
</div>

	<#if need_autocomplete>
		<div class="suggestionsBox" id="suggestions" style="display: none;">
			<div class="suggestionList" id="autoSuggestionsList">
			</div>
		</div>
	</#if>
<#else>
No Model Queryed
</#if>

</@crud.body>